package com.huilian.tool.work.weixin.service.impl;

import com.huilian.tool.work.weixin.dto.Department;
import com.huilian.tool.work.weixin.service.DepartmentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

/**
 * @Author 少凡
 * @Date 2022-06-25 09:31
 * version 1.0
 */
@Service
@Slf4j
public class DepartmentServiceImpl implements DepartmentService {

    @Resource
    private RestTemplate restTemplate;

    @Override
    public String create(String accessToken, Department department) {
        return null;
    }

    @Override
    public String update(String accessToken, Department department) {
        return null;
    }

    @Override
    public String delete(String accessToken, Integer id) {
        return null;
    }

    @Override
    public String list(String accessToken) {
        StringBuilder url = new StringBuilder("https://qyapi.weixin.qq.com/cgi-bin/department/list?access_token=").append(accessToken);
        String result = restTemplate.getForObject(url.toString(), String.class);
        System.out.println(result);
        return result;
    }

//    @Override
//    public List<Department> list(String accessToken, Integer id) {
//        String url = "https://qyapi.weixin.qq.com/cgi-bin/department/list?access_token=ACCESS_TOKEN&id=ID";
//        return null;
//    }
}
